<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!DOCTYPE html>
    <html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <link rel="stylesheet" href="css/Unstyle.css">
        <link rel="stylesheet" href="css/denglu.css">
    </head>

    <body>

        <div class="enroll-beijing">
            <div class="enroll-kuang">
                <div class="enroll-logo"><img src="img/4/logo.jpg" alt=""></div>
                <div class="enroll-biaoti">登录DJI账号</div>
                <div class="enroll-wenzi">用户名</div>
                <input type="text" name="" id="enroll-user">
                <div class="enroll-wenzi">密码</div>
                <input type="password" name="" id="enroll-password">
                <div class="enroll-wenzi">请验证</div>
                <div class="outBox">
                    <div class="slider">&rarr;</div>
                    <p id="remind">向右滑动</p>
                    <div class="slider_back"></div>
                </div>
                <input id="btnLogin" type="button" value="登录" />
                <div id="msg" style="height: 10px; width: 100px; margin-left: 15px;"></div>
                <div class="enroll-yiyou">没有账号? <span>注册DJI账号</span></div>


                <div class="disanfang">
                    <div class="disan-xian">
                        <div class="disan-wenzi">或使用第三方账号登陆</div>
                    </div> 
                </div>

                <div class="weixin">

                </div>



            </div>
        </div>


        <div class="denglu-tanchu">
           <div>
            <span>X</span>
           </div> 
        </div>
    </body>

    </html>
    <script src="js/jquery-3.2.1.min.js"></script>
    <script src="js/denglu.js"></script>
    <script>
        let oBtnLogin = document.getElementById("btnLogin");
        let oUserPass = document.getElementById("enroll-password"); 
        let oUserName = document.getElementById("enroll-user");
        oBtnLogin.onclick = function(){
        let xhr = new XMLHttpRequest();
        xhr.open("post","goodsAndShoppingCart/login.php",true);
    
        xhr.onreadystatechange = function(){
            if(xhr.readyState==4 && xhr.status==200){
                console.log(xhr.responseText)
               if(xhr.responseText=="﻿success"){
                   document.getElementById("msg").innerHTML = "登录成功";
                   setTimeout(() => {
          location.href = "index.html";
          sessionStorage.setItem("vipName",oUserName.value);
        }, 2000);
               }else{
                   document.getElementById("msg").innerHTML = "登录失败,用户名或者密码错误";
               }
            }
        }
    
        xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
        
        let str = "username="+oUserName.value+"&userpass="+oUserPass.value;
        xhr.send(str);
    }
    </script>

</html>